﻿//===================================================================
// 西交通开发框架-XCI.Parent 2019 版权所有     
//===================================================================
using System.ComponentModel.DataAnnotations;
using XCI.Core;

namespace XCI.Sys.Model
{
    /// <summary>
    /// 系统字典
    /// </summary>
    [ApiModel(Caption = "系统字典")]
    public class SysDic
    {
        /// <summary>
        /// 字典主键
        /// </summary>
        [Display(Name = "字典主键")]
        [ApiModelProperty(PrimaryKey = true)]
        public string Id { get; set; }

        /// <summary>
        /// 上级主键
        /// </summary>
        [Display(Name = "上级主键")]
        [ApiModelProperty(ParentKey = true)]
        public string ParentId { get; set; }

        /// <summary>
        /// 字典名称
        /// </summary>
        [Display(Name = "字典名称")]
        [Required(ErrorMessage = "请输入字典名称")]
        [StringLength(100, ErrorMessage = "字典名称不能超过100个字符")]
        public string Name { get; set; }

        /// <summary>
        /// 字典类型编码
        /// </summary>
        [Display(Name = "字典类型编码")]
        [Required(ErrorMessage = "请输入字典类型编码")]
        [StringLength(100, ErrorMessage = "字典类型编码不能超过100个字符")]
        public string Code { get; set; }

        /// <summary>
        /// 字典名称简拼
        /// </summary>
        [Display(Name = "字典名称简拼")]
        [StringLength(100, ErrorMessage = "字典名称简拼不能超过100个字符")]
        public string Spell { get; set; }

        /// <summary>
        /// 字典值
        /// </summary>
        [Display(Name = "字典值")]
        [Required(ErrorMessage = "请输入字典值")]
        [StringLength(500, ErrorMessage = "字典值不能超过500个字符")]
        public string Value { get; set; }

        /// <summary>
        /// 序号
        /// </summary>
        [Display(Name = "序号")]
        [ApiModelProperty(PathKey = true)]
        public int Path { get; set; }

        /// <summary>
        /// 状态 [true-启用, false-禁用]
        /// </summary>
        [Display(Name = "状态")]
        public bool Status { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Display(Name = "备注")]
        [StringLength(500, ErrorMessage = "备注不能超过500个字符")]
        public string Remark { get; set; }

        /// <summary>
        /// 字典类型
        /// </summary>
        [Display(AutoGenerateField = false)]
        public SysDicCategory DicCategory { get; set; }

        /// <summary>
        /// 字典类型显示内容
        /// </summary>
        public string DicCategoryString => $"{DicCategory?.Name} - {DicCategory?.Code}";

        /// <summary>
        /// 复制对象
        /// </summary>
        public SysDic Clone()
        {
            return (SysDic)MemberwiseClone();
        }
    }
}
